package ar.com.jendrix.common.web;

import javax.faces.event.ActionEvent;

import ar.com.jendrix.common.exception.ApplicationException;
import ar.com.jendrix.common.exception.SystemException;

@SuppressWarnings("serial")
public abstract class ProcessBaseBean extends SearchBean {

	/**
	 */
	public final void process(ActionEvent actionEvent) {
		try {
			doProcess();
			doAfterProcess();
			clear();
		} catch (ApplicationException a) {
			addErrorMessages(a.getMessages());
		} catch (Throwable t) {
			log.error(t.getMessage(), t);
			addErrorMessage("Error al procesar");
		}
	}

	/**
	 */
	protected abstract void doProcess() throws ApplicationException, SystemException;

	/**
	 */
	protected void doAfterProcess() throws ApplicationException, SystemException {
	}
}